#include "CObject.h"

UINT CObject::m_sID = 10000;

CObject::CObject():
m_ID(++m_sID)
{
	m_Pos.x = 0;
	m_Pos.y = 0;
	m_SrcSize.cx = 0;
	m_SrcSize.cy = 0;
	m_Size.cx = 0;
	m_Size.cy = 0;
}

CObject::~CObject()
{
	m_hDCs.clear();
}

UINT CObject::GetID() const
{
	return m_ID;
}

void CObject::SetPos(int x, int y)
{
	m_Pos.x = x;
	m_Pos.y = y;
}

POINT CObject::GetPos()
{
	return m_Pos;
}

void CObject::SetSize(int w, int h)
{
	m_Size.cx = w;
	m_Size.cy = h;
}

SIZE CObject::GetSize()
{
	return m_Size;
}

RECT CObject::GetRect()
{
	RECT rect;
	rect.left = m_Pos.x;
	rect.top = m_Pos.y;
	rect.right = m_Pos.x + m_Size.cx;
	rect.bottom = m_Pos.y + m_Size.cy;
	return rect;
}

void CObject::SetMidpoint(POINT pt)
{
	m_Pos.x = pt.x - m_Size.cx / 2;
	m_Pos.y = pt.y - m_Size.cy / 2;
}

POINT CObject::GetMidpoint()
{
	POINT pt;
	pt.x = m_Pos.x + m_Size.cx / 2;
	pt.y = m_Pos.y + m_Size.cy / 2;
	return pt;
}